package com.example.demo.model.activiti;

import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
public class Task implements Serializable {
    private static final long serialVersionUID = 1834574316566925238L;

    private String id;
    private String name;
    private String description;
    private int priority;
    private String owner;
    private String assignee;
    private String processInstanceId;
    private String executionId;
    private String processDefinitionId;
    private Date createTime;
    private String taskDefinitionKey;
    private Date dueDate;
    private String category;
    private String parentTaskId;
    private String tenantId;
    private String formKey;

    public static Task createTaskInformaticFromActiviti(org.activiti.engine.task.Task task){
        if (task == null) return null;
        Task taskresult = new Task();
        if (task.getId() != null) {
            taskresult.setId(task.getId());
        }
        if (task.getName() != null) {
            taskresult.setName(task.getName());
        }
        if (task.getDescription() != null) {
            taskresult.setDescription(task.getDescription());
        }
        taskresult.setPriority(task.getPriority());
        if (task.getOwner() != null) {
            taskresult.setOwner(task.getOwner());
        }
        if (task.getAssignee() != null) {
            taskresult.setAssignee(task.getAssignee());
        }
        if (task.getProcessInstanceId() != null) {
            taskresult.setProcessInstanceId(task.getProcessInstanceId());
        }
        if (task.getExecutionId() != null) {
            taskresult.setExecutionId(task.getExecutionId());
        }
        if (task.getProcessDefinitionId() != null) {
            taskresult.setProcessDefinitionId(task.getProcessDefinitionId());
        }
        if (task.getCreateTime() != null) {
            taskresult.setCreateTime(task.getCreateTime());
        }
        if (task.getTaskDefinitionKey() != null) {
            taskresult.setTaskDefinitionKey(task.getTaskDefinitionKey());
        }
        if (task.getDueDate() != null) {
            taskresult.setDueDate(task.getDueDate());
        }
        if (task.getCategory() != null) {
            taskresult.setCategory(task.getCategory());
        }
        if (task.getParentTaskId() != null) {
            taskresult.setParentTaskId(task.getParentTaskId());
        }
        if (task.getTenantId() != null) {
            taskresult.setTenantId(task.getTenantId());
        }
        if (task.getFormKey() != null) {
            taskresult.setFormKey(task.getFormKey());
        }
        return taskresult;
    }
}
